import 'package:honeypotflutter/modules/home/model/home_modulesModel.dart';
import 'package:honeypotflutter/router/bussine_router_url.dart';

class HomeModulesData {
  //数据
  static final List<HomeModulesModel> modulesList = _modulesList();

  /*
  * 获取数据
  * */
  static List<HomeModulesModel> _modulesList() {
    List<HomeModulesModel> modulesArray = <HomeModulesModel>[];
    {
      HomeModulesModel model = HomeModulesModel();
      model.id = 1;
      model.label = "投递(旧)";
      model.image = "home_deliver";
      model.url = MGRouterUrl.deliver_scanf;
      modulesArray.add(model);
    }
    {
      HomeModulesModel model = HomeModulesModel();
      model.id = 2;
      model.label = "空箱查询";
      model.image = "home_box";
      model.url = MGRouterUrl.emptyHire;
      modulesArray.add(model);
    }
    {
      HomeModulesModel model = HomeModulesModel();
      model.id = 3;
      model.label = "包裹查询";
      model.image = "home_bag";
      model.url = MGRouterUrl.package;
      modulesArray.add(model);
    }
    {
      HomeModulesModel model = HomeModulesModel();
      model.id = 4;
      model.label = "租用格口";
      model.image = "home_box_rent";
      model.url = MGRouterUrl.hire;
      modulesArray.add(model);
    }
    {
      HomeModulesModel model = HomeModulesModel();
      model.id = 5;
      model.label = "快速充值";
      model.image = "home_pay";
      model.url = MGRouterUrl.recharge;
      modulesArray.add(model);
    }
    {
      HomeModulesModel model = HomeModulesModel();
      model.id = 6;
      model.label = "上门服务";
      model.image = "home_server";
      model.url = MGRouterUrl.preferences_list;
      modulesArray.add(model);
    }
    {
      HomeModulesModel model = HomeModulesModel();
      model.id = 7;
      model.label = "送餐服务";
      model.image = "home_send";
      modulesArray.add(model);
    }
    {
      HomeModulesModel model = HomeModulesModel();
      model.id = 9;
      model.label = "实名认证";
      model.image = "home_realName";
      model.url = MGRouterUrl.autonym;
      modulesArray.add(model);
    }
    {
      HomeModulesModel model = HomeModulesModel();
      model.id = 10;
      model.label = "故障报修";
      model.image = "home_repair";
      modulesArray.add(model);
    }
    {
      HomeModulesModel model = HomeModulesModel();
      model.id = 11;
      model.label = "签收设置";
      model.image = "home_setting";
      model.url = MGRouterUrl.sign_for;
      modulesArray.add(model);
    }
    {
      HomeModulesModel model = HomeModulesModel();
      model.id = 12;
      model.label = "工单记录";
      model.image = "home_history";
      model.url = MGRouterUrl.tickets_list;
      modulesArray.add(model);
    }
    {
      HomeModulesModel model = HomeModulesModel();
      model.id = 13;
      model.label = "柜机管理";
      model.image = "home_boxManage";
      model.url = MGRouterUrl.cabinet;
      modulesArray.add(model);
    }
    return modulesArray;
  }

  /*
  * 数据查找
  * */
  static HomeModulesModel findOneModules(int? id) {
    if (id == null) {
      return _defaultModel();
    }
    var printList = modulesList.where((element) => element.id == id).toList();
    if (printList.isEmpty) {
      return _defaultModel();
    }
    return printList.first;
  }

  /*
  * 默认对象
  * */
  static HomeModulesModel _defaultModel() {
    HomeModulesModel model = HomeModulesModel();
    model.id = 9999;
    model.label = "暂无";
    model.image = "home_default";
    return model;
  }
}
